package controller.v2;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;

import model.AddressVO;
import model.DicVO;
import model.GoodVO;
import model.LogTicketVO;
import model.MemberVO;
import model.PackageVO;
import model.PageEarnVO;
import model.ShareVO;
import model.UorderVO;
import service.v2.AddressService;
import service.v2.AwardService;
import service.v2.CatService;
import service.v2.ConfigService;
import service.v2.DicService;
import service.v2.GoodService;
import service.v2.LogTicketService;
import service.v2.MemberItemService;
import service.v2.MemberService;
import service.v2.MemberTicketService;
import service.v2.MoneyService;
import service.v2.OrderService;
import service.v2.PackageService;
import service.v2.ShareService;
import service.v2.UorderService;
import util.DateParseUtil;
import util.NumberUtil;
import util.PackageUtil;
import util.PropertieUtil;
import util.StringUtil;

@Controller
@RequestMapping("/v2/member")
public class MemberController {
	@Autowired
	private MemberService memberService;
	@Autowired
	private AwardService awardService; 
	@Autowired
	private PackageService packageService;
	@Autowired
	private DicService dicService;
	@Autowired
	private MemberItemService memberItemService;
	@Autowired
	private OrderService orderService;
	@Autowired
	private ConfigService configService;
	@Autowired
	private UorderService uorderService;
	@Autowired
	private GoodService goodService;
	@Autowired
	private MoneyService moneyService;
	@Autowired
	private MemberTicketService memberTicketService;
	@Autowired
	private CatService catService;
	@Autowired
	private ShareService shareService;
	@Autowired
	private AddressService addressService;
	@Autowired
	private LogTicketService logTicketService;
	
	/**
	 * @param token 令牌
	 * @param member_id 用户ID
	 * @return 用户信息
	 */
	@ResponseBody
	@RequestMapping(value="/memberInfo",method=RequestMethod.GET)
	public Object memberInfo(@RequestHeader(value = "LANG", required = false) String lang,@RequestHeader (value="AUTHORIZATION", required=false) String token,@RequestHeader (value="SECRET", required=false)  String member_id
			,HttpServletRequest request, HttpServletResponse response, MemberVO memberVO){
		memberVO = memberService.getLoginMemberById(member_id);
		memberVO.setDanger_state("4".equals(memberVO.getIdcard_state())&&"1".equals(memberVO.getHas_pay_pwd())?"1":"0");
		Map<String, Object> map = new HashMap<String, Object>();
		String host = configService.loadConfig("HOST");
		String version=configService.loadConfig("VERSION");
		int waitPayNum = 0;//待付款
		int waitSendNum = 0;//待发货
		int waitGetNum = 0;//待收货
		int waitEvaNum = 0;//待评价
		int waitBackNum = 0;//待退款
		List<UorderVO> caseState = uorderService.getCaseCount(member_id,lang);
		for (int i = 0; i < caseState.size(); i++) {
			if("1".equals(caseState.get(i).getState())){
				waitPayNum = waitPayNum + Integer.parseInt(caseState.get(i).getState_count());
			}
			else if("3".equals(caseState.get(i).getState())||"8".equals(caseState.get(i).getState())){
				waitSendNum = waitSendNum + Integer.parseInt(caseState.get(i).getState_count());
			}
			else if("4".equals(caseState.get(i).getState())||"7".equals(caseState.get(i).getState())){
				waitGetNum = waitGetNum + Integer.parseInt(caseState.get(i).getState_count());
			}
			else if("5".equals(caseState.get(i).getState())){
				waitEvaNum = waitEvaNum + Integer.parseInt(caseState.get(i).getState_count());
			}
			else if("7".equals(caseState.get(i).getState())){
				waitBackNum = waitBackNum + Integer.parseInt(caseState.get(i).getState_count());
			}
		}
		String member_level_logo=memberService.getMemberLevelLogo(memberVO.getLevel());
		
		memberVO.setWaitBackNum(waitBackNum+"");
		memberVO.setWaitEvaNum(waitEvaNum+"");
		memberVO.setWaitGetNum(waitGetNum+"");
		memberVO.setWaitPayNum(waitPayNum+"");
		memberVO.setWaitSendNum(waitSendNum+"");
		memberVO.setNovip_url(host+version+"/member/noVip");
		if(memberVO.getLevel_ord()==null){
			memberVO.setLevel_ord("");
		}
		map.put("member", memberVO);
		map.put("waitPayNum", waitPayNum);
		map.put("waitSendNum", waitSendNum);
		map.put("waitGetNum", waitGetNum);
		map.put("waitEvaNum", waitEvaNum);
		map.put("waitBackNum", waitBackNum);
		map.put("invite_reg_url", configService.loadConfig("WECHAT_HOST")+"/my_inviteRegister?ym_share_inviteno="+memberVO.getInvite_no());
		//普通会员 会员升级
		map.put("levelupinfo_url",host+version+"/member/levelupInfo");
		//	map.put("levelupinfo_url","http://10.0.0.68:8080/v2/member/levelupInfo");
		map.put("member_upgrade_url",host+version+"/member/memberAward");
		//map.put("member_upgrade_url","http://10.0.0.68:8080/v2/member/memberAward");
		map.put("invitationfriend_url",host+version+"/friend/invitationFriend");
		//map.put("invitationfriend_url","http://10.0.0.68:8080/v2/friend/invitationFriend");
		//还不是付费会员画面
		map.put("novip_url",host+version+"/member/noVip");
		//	map.put("novip_url","http://10.0.0.68:8080/v2/member/noVip");
		//友米商学院
		map.put("schoolIndex_url",host+version+"/college/schoolIndex");
		//map.put("schoolIndex_url","http://10.0.0.68:8080/v2/college/schoolIndex");

		map.put("member_level_logo", member_level_logo);
		
		return PackageUtil.packageParams(200,"successs",map,""); 
	}
	
	/**
	 * 总代理进阶详情
	 * @param token 令牌
	 * @param member_id 用户ID
	 * @return 用户信息
	 * @throws Exception 
	 */

	@RequestMapping(value="/masterInfo",method=RequestMethod.GET)
	public String masterInfo(@RequestHeader(value = "LANG", required = false) String lang,
			@RequestHeader (value="AUTHORIZATION", required=false) String token,
			@RequestHeader (value="SECRET", required=false)  String member_id,HttpServletRequest request, HttpServletResponse response, MemberVO memberVO) throws Exception{
		//当前会员福利要求
		memberVO = memberService.getLoginMemberById(member_id);
		
		String host = configService.loadConfig("HOST");

		MemberVO curMember = memberService.getCurMemberInfo(member_id);
		//下级为专家的数量
//		String level_num = memberService.getSpecificChildNum(member_id, PropertieUtil.loadPropertie("expert_level"));
		//团队有专家以上等级的数量
		String level_num  = memberService.getUpExpertNum(member_id, PropertieUtil.loadPropertie("expert_level"));
		curMember.setLevel_num(level_num);
		//所有下级 包括自己的数量
		String childrenNum = memberService.getChildrenNum(member_id);
		curMember.setChildren_num(childrenNum);
		//总代理福利要求
		MemberVO masterMember = memberService.getMasterMemberInfo(PropertieUtil.loadPropertie("master_level"));
		//总代理名
	    String masterName = dicService.getNameById(PropertieUtil.loadPropertie("master_level"));
	    //高级代理
	    String expertName = dicService.getNameById(PropertieUtil.loadPropertie("expert_level"));
	    //普通会员
	    String commonName = dicService.getNameById(PropertieUtil.loadPropertie("common_level"));
	    //高级会员
	    String vip_level = dicService.getNameById(PropertieUtil.loadPropertie("vip_level"));
	    
	    if(lang ==null){
	    	request.setAttribute("cur", curMember);
	 		request.setAttribute("master", masterMember);
	 		request.setAttribute("memberVO", memberVO);
	 	    request.setAttribute("masterName", masterName);
	 		request.setAttribute("expertName", expertName);
	 		request.setAttribute("commonName", commonName);
	 		request.setAttribute("vip_level", vip_level);
	 		request.setAttribute("host_url",host);
	 		//兑换券名称从数据库查出来。
		    request.setAttribute("ticket_name",configService.loadConfig("TICKET_NAME"));
	 		
	 		return "/app/member/masterInfo"; 
	    }else{
	    	response.setContentType("text/json;charset=utf-8");   
			PrintWriter out = response.getWriter(); 
			
			Map map  =  new HashMap();
			map.put("cur", curMember);
	 		map.put("master", masterMember);
	 		map.put("memberVO", memberVO);
	 	    map.put("masterName", masterName);
	 		map.put("expertName", expertName);
	 		map.put("commonName", commonName);
	 		map.put("vip_level", vip_level);
	 		map.put("host_url",host);
	 		map.put("ticket_name",configService.loadConfig("TICKET_NAME"));
	 		
	        out.print(JSON.toJSONString(PackageUtil.packageParams(200, "success", map, "")));
	        out.flush();
	        out.close();
	      return null;
	    }
	}
	
	/**
	 * 会员升级中转方法 
	 * 根据等级跳转到指定的方法
	 * 127 126 levelupInfo
	 * 其他 MembershipUpgrade
	 */
	@RequestMapping(value="/levelupForward",method=RequestMethod.GET)
	public String levelupForward(@RequestHeader (value="OS", required=false) String os,@RequestHeader (value="AUTHORIZATION", required=false) String token,@RequestHeader (value="SECRET", required=false)  String member_id,HttpServletRequest request, HttpServletResponse response, MemberVO memberVO) throws Exception{
		memberVO = memberService.getLoginMemberById(member_id);
		if("1".equals(memberVO.getExp_state())){
			memberVO.setLevel(PropertieUtil.loadPropertie("common_level"));
		}
		if("126".equals(memberVO.getLevel())||"127".equals(memberVO.getLevel())){
			return "forward:levelupInfo";
		}else{
			String version=configService.loadConfig("VERSION");
			return "forward:"+version+"/memberticket/MembershipUpgrade";
		}
	}
	
	
	/**
	 * 会员进阶代理详情
	 * @param token 令牌
	 * @param member_id 用户ID
	 * @throws Exception 
	 */
	@RequestMapping(value="/levelupInfo",method=RequestMethod.GET)
	public String levelupInfo(@RequestHeader(value = "LANG", required = false) String lang,@RequestHeader (value="OS", required=false) String os,@RequestHeader (value="AUTHORIZATION", required=false) String token,@RequestHeader (value="SECRET", required=false)  String member_id,HttpServletRequest request, HttpServletResponse response, MemberVO memberVO) throws Exception{
		if(os != null){
			os = os.toLowerCase();
		}
		List<MemberVO> list = new ArrayList<MemberVO>();
		memberVO = memberService.getLoginMemberById(member_id);
		if("1".equals(memberVO.getExp_state())){
			memberVO.setLevel(PropertieUtil.loadPropertie("common_level"));
		}
		if("126".equals(memberVO.getLevel())||"127".equals(memberVO.getLevel())){
			list = memberService.getLevlupInfo(PropertieUtil.loadPropertie("agency_identify"),memberVO.getHistory_total_ticket());
		}else{
			response.setContentType("text/json;charset=utf-8");   
			PrintWriter out = response.getWriter(); 
			out.print(JSON.toJSONString(PackageUtil.packageParams(403,"forbidden","","")) );
			out.flush();
			out.close();
			return null;
		}
		String host = configService.loadConfig("HOST");
		String version=configService.loadConfig("VERSION");
		String ticket_name=configService.loadConfig("TICKET_NAME");	
		String app_name=configService.loadConfig("APP_NAME");	
		
		//总代理名
		String masterName = dicService.getNameById(PropertieUtil.loadPropertie("master_level"));
		//查询升级银卡会员时的套餐商品价(这个价替代原先查询的升级银卡价格.)
		PackageVO p = packageService.getPackageListOne(lang);
		String default_price= p.getGood_list().get(0).getDefault_price();
		if(lang==null){
			request.setAttribute("list", list);
			request.setAttribute("os",os);
			request.setAttribute("masterinfo_url",host+version+"/member/masterInfo");
			//request.setAttribute("masterinfo_url","http://10.0.0.68:8080/v2/member/masterInfo");
			request.setAttribute("ticket_name",ticket_name);
			request.setAttribute("host_url",host);
			request.setAttribute("masterName",masterName);
			request.setAttribute("registerProtocol_url",host+version+"/page/registerProtocol");
			//request.setAttribute("registerProtocol_url","http://10.0.0.68:8080/v2/page/registerProtocol");
			request.setAttribute("memberLevelup",host+version+"/member/memberLevelup");
			//request.setAttribute("memberLevelup","http://10.0.0.68:8080/v2/member/memberLevelup");
			request.setAttribute("app_name",app_name);
			request.setAttribute("default_price",default_price);
			return "/app/member/levelupInfo"; 
		}else{
			String rate_dollar=configService.loadConfig("RATE_DOLLAR");	
			Map map = new HashMap();
			map.put("list", list);
			map.put("os",os);
			map.put("masterinfo_url",host+version+"/member/masterInfo");
			map.put("ticket_name",ticket_name);
			map.put("host_url",host);
			map.put("masterName",masterName);
			map.put("registerProtocol_url",host+version+"/page/registerProtocol");
			map.put("memberLevelup",host+version+"/member/memberLevelup");
			map.put("app_name",app_name);
			map.put("rate_dollar",rate_dollar);
			map.put("default_price",default_price);

			response.setContentType("text/html;charset=utf-8");
			PrintWriter out = response.getWriter();
	        out.print(JSON.toJSONString(PackageUtil.packageParams(200, "success", map, "")));
	        out.flush();
	        return null;	
		}
		
	}
	
	/**
	 * 会员进阶代理详情
	 * @param token 令牌
	 * @param member_id 用户ID
	 * @param level 级别ID
	 * @param package_id 套餐
	 * @throws Exception 
	 */
	@RequestMapping(value="/memberLevelup",method=RequestMethod.GET)
	public String memberLevelup(@RequestHeader(value = "LANG", required = false) String lang,
			@RequestHeader (value="AUTHORIZATION", required=false) String token,@RequestHeader (value="OS", required=false) String os,
			@RequestHeader (value="SECRET", required=false)  String member_id,HttpServletRequest request, 
			HttpServletResponse response, MemberVO memberVO,String level, String package_id,String isJSON,String address_id,String standard_id) throws Exception{
		/*member_id="3595";	
		level="125";
		os="ios";*/
		if(os != null){
			os = os.toLowerCase();
		}
		String host = configService.loadConfig("HOST");
		String version=configService.loadConfig("VERSION");
		String ticket_logo=configService.loadConfig("TICKET_LOGO");
		AddressVO defaultAddress =new AddressVO();
		MemberVO m =  new MemberVO();
		PackageVO p = new PackageVO();
		Map<String, Object> map = new HashMap<String, Object>();
		String address =null;
		memberVO = memberService.getLoginMemberById(member_id);
		//判断级别ID
		if(level==null || "".equals(level)){
			response.setContentType("text/json;charset=utf-8");   
			PrintWriter out = response.getWriter(); 
			out.print(JSON.toJSONString(PackageUtil.packageParams(10001,"缺少必选参数","","")) );
			out.flush();
			out.close();
			return null;
		}
		//判断要升级的级别ID 为代理并且不为大师
		List<String> levelList = dicService.getChildrenNum(PropertieUtil.loadPropertie("agency_identify"));
		if(!levelList.contains(level) || PropertieUtil.loadPropertie("master_level").equals(level)){
			response.setContentType("text/json;charset=utf-8");   
			PrintWriter out = response.getWriter(); 
			out.print(JSON.toJSONString(PackageUtil.packageParams(10000,"参数错误，请参考API文档","","")) );
			out.flush();
			out.close();
			return null;
		}
		String level_ord=memberItemService.getOrdBylevel(level);
		
		//普通会员 套餐
		if(PropertieUtil.loadPropertie("primary_level").equals(level)){
			String rate = "";
			if(PropertieUtil.loadPropertie("vip_level").equals(memberVO.getLevel()) || PropertieUtil.loadPropertie("common_level").equals(memberVO.getLevel())){
				rate = memberItemService.getRateByLevel(PropertieUtil.loadPropertie("primary_level"));
			}else{
				rate = memberItemService.getRateByLevel(memberVO.getLevel());
			}
			List<PackageVO> packageList = packageService.getPackageListAll(lang);
			if(packageList.size() != 0){
				packageList.get(0).setStandard_id(packageList.get(0).getGood_list().get(0).getStandard_id());
			}
			
			DicVO dicVO = dicService.getDicById(level);
			m.setLevel_name(dicVO.getName());
			//购买套餐
			if(package_id==null && standard_id ==null){
				p = packageService.getPackageListOne(lang);
				m.setRecharge_ticket(packageList.get(0).getRecharge_ticket());
			}
			if(package_id !=null && standard_id !=null){
				p = packageService.getPackageByPackageIdAndStandardId(package_id,standard_id);
				m.setRecharge_ticket(p.getRecharge_ticket());
			}
			standard_id= p.getGood_list().get(0).getStandard_id();
			m.setRate(rate);
			p.setDefaultPrice(p.getGood_list().get(0).getDefault_price());
			if(!"1".equals(isJSON)){
				request.setAttribute("package_list", packageList);
				request.setAttribute("level", level);
				request.setAttribute("standard_id", standard_id);
				request.setAttribute("packageOne", p);
				request.setAttribute("level_up_info", m);
				request.setAttribute("package_buy", 1);
			    request.setAttribute("package_url",host+version+"/member/memberLevelupPackageList");
				//request.setAttribute("package_url","http://10.0.0.68:8080/v2/member/memberLevelupPackageList");
			}else{
				map.put("package_list", packageList);
				map.put("level_up_info", m);
				map.put("package_buy", 1);
				map.put("p", p);
				map.put("rate_dollar",configService.loadConfig("RATE_DOLLAR"));
			}
			
			//普通以上会员 提货券
		}else{
		
			MemberVO memberLevelUpInfo = memberItemService.getCurMemberLevelUpInfo(level,memberVO.getHistory_total_ticket());
			
			double cash =Double.parseDouble(memberLevelUpInfo.getLevel_up_cash());
			
			//小数点处理 不到1元进一
			if(cash<1 && cash>0){
					memberLevelUpInfo.setLevel_up_cash(cash+"");
			}else{
				memberLevelUpInfo.setLevel_up_cash(NumberUtil.formatDouble((int)cash,2));
			}
			if(!"1".equals(isJSON)){
				request.setAttribute("package_list", new ArrayList());
				request.setAttribute("level_up_info", memberLevelUpInfo);
				request.setAttribute("package_buy", 0);
			}else{
				map.put("package_list", new ArrayList());
				map.put("level_up_info", memberLevelUpInfo);
				map.put("package_buy", 0);
			}
		}
		if(!"1".equals(isJSON)){
			//收获地址
			if(address_id !=null){
				defaultAddress = addressService.getAddressById(address_id);
			}else{
				defaultAddress = addressService.getDefaultAddress(member_id);
			}
			if(defaultAddress !=null){
				 address = addressService.tempAddress(defaultAddress);
				 address_id = defaultAddress.getAddress_id();
			}
			
			request.setAttribute("ticket_logo", ticket_logo);
			request.setAttribute("free_cash", memberVO.getFree_cash());
			request.setAttribute("address_id", address_id);
			request.setAttribute("level_ord", level_ord);
			request.setAttribute("address", address);
			request.setAttribute("os", os);
			request.setAttribute("memberId", member_id);
			request.setAttribute("token", token);
			request.setAttribute("free_cash", memberVO.getFree_cash());
			return "/app/member/memberLevelup";
		}else{
			map.put("ticket_logo",ticket_logo);
			map.put("free_cash", memberVO.getFree_cash());
			map.put("level_ord", level_ord);
			String rate_dollar=configService.loadConfig("RATE_DOLLAR");	
			map.put("rate_dollar",rate_dollar);
			
			response.setContentType("text/json;charset=utf-8");   
			PrintWriter out = response.getWriter();
	        out.print(JSON.toJSONString(PackageUtil.packageParams(200, "success", map, "")));
	        out.flush();
	        return null;
		}
	}
	/**
	 * @param token 令牌
	 * @param member_id 用户ID
	 * @return noVip
	 * @throws Exception 
	 */
	
	@RequestMapping(value="/memberLevelupPackageList",method=RequestMethod.GET)
	public String memberLevelupPackageList(@RequestHeader(value = "LANG", required = false) String lang,@RequestHeader (value="OS", required=false) String os,
			@RequestHeader (value="AUTHORIZATION", required=false) String token,
			@RequestHeader (value="SECRET", required=false)  String member_id,HttpServletRequest request, 
			HttpServletResponse response, MemberVO memberVO,String level, String packageId,String isJSON,
			String standard_id) throws Exception{
		if(os != null){
			os = os.toLowerCase();
		}
		/*member_id="3861";	
		level="125";
		package_id="89";
		os="ios";*/
		//判断级别ID
		if(level==null || "".equals(level)){
			response.setContentType("text/json;charset=utf-8");   
			PrintWriter out = response.getWriter(); 
			out.print(JSON.toJSONString(PackageUtil.packageParams(10001,"缺少必选参数","","")) );
			out.flush();
			out.close();
			return null;
		}
		if(!PropertieUtil.loadPropertie("primary_level").equals(level)){
			response.setContentType("text/json;charset=utf-8");   
			PrintWriter out = response.getWriter(); 
			out.print(JSON.toJSONString(PackageUtil.packageParams(10000,"参数错误，请参考API文档","","")) );
			out.flush();
			out.close();
			return null;
		}
		String rate = memberItemService.getRateByLevel(PropertieUtil.loadPropertie("primary_level"));
		List<PackageVO> packageList = packageService.getPackageListAll(lang);
		String standard_name = "";
		String default_price = "";
		if(packageId !=null && standard_id !=null){
			PackageVO p = packageService.getPackageByPackageIdAndStandardId(packageId,standard_id);
			 standard_name = p.getGood_list().get(0).getStandard_name();
			 default_price = p.getGood_list().get(0).getDefault_price();
		}
	
		if(packageList.size() != 0){
			if(packageId==null){
				packageId=packageList.get(0).getPackage_id();
			}
			for(int i=0;i<packageList.size();i++){
				packageList.get(i).setStandard_id(packageList.get(i).getGood_list().get(0).getStandard_id());
				packageList.get(i).setGood_id(packageList.get(i).getGood_list().get(0).getGood_id());
				packageList.get(i).setDefaultPrice(packageList.get(i).getGood_list().get(0).getDefault_price());
			}
		}
		request.setAttribute("ticket_logo", configService.loadConfig("TICKET_LOGO"));
		request.setAttribute("packageList", packageList);
		request.setAttribute("package_id", packageId);
		request.setAttribute("standard_name", standard_name);
		request.setAttribute("default_price", default_price);
		request.setAttribute("rate", rate);
		request.setAttribute("os", os);
		request.setAttribute("level", level);
		return "/app/member/packageList";
	}
	@ResponseBody
	@RequestMapping(value="/memberLevelup1",method=RequestMethod.GET)
	public Object memberLevelup1(@RequestHeader(value = "LANG", required = false) String lang,@RequestHeader (value="AUTHORIZATION", required=false) String token,@RequestHeader (value="SECRET", required=false)  String member_id,HttpServletRequest request, HttpServletResponse response, MemberVO memberVO,String level, String package_id) throws Exception{
		memberVO = memberService.getLoginMemberById(member_id);
		//判断级别ID
		if(level==null || "".equals(level)){
			return PackageUtil.packageParams(10001,"缺少必选参数，请参考API文档","",""); 
		}
		
		//判断要升级的级别ID 为代理并且不为大师
		List<String> levelList = dicService.getChildrenNum(PropertieUtil.loadPropertie("agency_identify"));
		if(!levelList.contains(level) || PropertieUtil.loadPropertie("master_level").equals(level)){
			return PackageUtil.packageParams(10000,"参数错误，请参考API文档","",""); 
		}
		Map<String, Object> map = new HashMap<String, Object>();
		//普通会员 套餐
//		if(PropertieUtil.loadPropertie("common_level").equals(memberVO.getLevel())){   //原来的版本 不用了
		if(PropertieUtil.loadPropertie("primary_level").equals(level)){
			List<PackageVO> packageList = packageService.getPackageListAll(lang);
			if(packageList.size() != 0){
				packageList.get(0).setStandard_id(packageList.get(0).getGood_list().get(0).getStandard_id());
			}
			map.put("package_list", packageList);
			MemberVO m =  new MemberVO();
			PackageVO p =  new PackageVO();
			DicVO dicVO = dicService.getDicById(level);
			m.setLevel_name(dicVO.getName());
			//购买套餐
			if(package_id==null){
				p = packageService.getPackageListOne(lang);
				m.setRecharge_ticket(packageList.get(0).getRecharge_ticket());
				//分享套餐
			}else{
				 p = packageService.getPackageById(package_id);
				m.setRecharge_ticket(p.getRecharge_ticket());
			}
			String rate = "";
			if(PropertieUtil.loadPropertie("vip_level").equals(memberVO.getLevel()) || PropertieUtil.loadPropertie("common_level").equals(memberVO.getLevel())){
				rate = memberItemService.getRateByLevel(PropertieUtil.loadPropertie("primary_level"));
			}else{
				rate = memberItemService.getRateByLevel(memberVO.getLevel());
			}
			m.setRate(rate);
			map.put("level_up_info", m);
			map.put("package_buy", 1);
			map.put("p", p);
			//普通以上会员 提货券
		}else{
		
			map.put("package_list", new ArrayList());
			MemberVO memberLevelUpInfo = memberItemService.getCurMemberLevelUpInfo(level,memberVO.getHistory_total_ticket());
			
			double cash =Double.parseDouble(memberLevelUpInfo.getLevel_up_cash());
			
			//小数点处理 不到1元进一
			if(cash<1 && cash>0){
					memberLevelUpInfo.setLevel_up_cash(cash+"");
			}else{
				memberLevelUpInfo.setLevel_up_cash(NumberUtil.formatDouble((int)cash,2));
			}
						
			map.put("level_up_info", memberLevelUpInfo);
			map.put("package_buy", 0);
		
		}
		
		
		map.put("ticket_logo", configService.loadConfig("TICKET_LOGO"));
		map.put("free_cash", memberVO.getFree_cash());
		return PackageUtil.packageParams(200,"successs",map,""); 
	}
	
	/**
	 * 会员套餐
	 * @param token 令牌
	 * @param member_id 用户ID
	 * @param level 级别ID
	 * @throws Exception 
	 */
	@ResponseBody
	@RequestMapping(value="/memberPackageList",method=RequestMethod.GET)
	public Object memberPackageList(@RequestHeader(value = "LANG", required = false) String lang,@RequestHeader (value="AUTHORIZATION", required=false) String token,@RequestHeader (value="SECRET", required=false)  String member_id,HttpServletRequest request, 
			HttpServletResponse response, MemberVO memberVO,String level) throws Exception{
		memberVO = memberService.getLoginMemberById(member_id);
		//判断级别ID
		if(level==null || "".equals(level)){
			return PackageUtil.packageParams(10001,"缺少必选参数，请参考API文档","",""); 
		}
		//判断要升级的级别ID
		/*List<String> levelList = dicService.getChildrenNum(PropertieUtil.loadPropertie("agency_identify"));
		if(!levelList.contains(level) || PropertieUtil.loadPropertie("master_level").equals(level)){
			return PackageUtil.packageParams(10000,"参数错误，请参考API文档","",""); 
		}*/
		//判断是普通会员
		if(!PropertieUtil.loadPropertie("common_level").equals(memberVO.getLevel())){
			return PackageUtil.packageParams(10000,"参数错误，请参考API文档","",""); 
		}
		List<PackageVO> packageList = packageService.getPackageListAll(lang);
		return PackageUtil.packageParams(200,"successs",packageList,""); 
	}
	
	/**
	 * @param token 令牌
	 * @param member_id 用户ID
	 * @return 注册推送
	 */
	@ResponseBody
	@RequestMapping(value="/memberPushReg",method=RequestMethod.POST)
	public Object memberPushReg(@RequestHeader (value="AUTHORIZATION", required=false) String token,@RequestHeader (value="SECRET", required=false)  String member_id
			,HttpServletRequest request, HttpServletResponse response){
		memberService.regPushId(member_id, member_id);
		return PackageUtil.packageParams(200,"successs","",""); 
	}
	
	/**
	 * @param token 令牌
	 * @param member_id 用户ID
	 * @return 注销推送
	 */
	@ResponseBody
	@RequestMapping(value="/memberPushLogout",method=RequestMethod.POST)
	public Object memberPushLogout(@RequestHeader (value="AUTHORIZATION", required=false) String token,@RequestHeader (value="SECRET", required=false)  String member_id
			,HttpServletRequest request, HttpServletResponse response, String push_id){
		memberService.regPushId(member_id, null);
		return PackageUtil.packageParams(200,"successs","",""); 
	}
	/**
	 * 弹窗
	 * @param token
	 * @param member_id
	 */
	@ResponseBody
	@RequestMapping(value="/commonPopUp",method=RequestMethod.POST)
	public Object commonPopUp(@RequestHeader(value = "LANG", required = false) String lang,@RequestHeader (value="OS", required=false) String os,@RequestHeader (value="AUTHORIZATION", required=false) String token,
			@RequestHeader (value="SECRET", required=false)  String member_id,HttpServletRequest request, HttpServletResponse response, MemberVO memberVO)throws Exception{
		if(os != null){
			os = os.toLowerCase();
		}
		memberVO=memberService.getAllInfoById(member_id);
		memberVO.setMember_id(member_id);
		Map map = memberService.getCommonPopUpInfo(memberVO,os,"1",lang);
		return PackageUtil.packageParams(200,"successs",map,""); 
	}
	/**
	 * @param token 令牌
	 * @param member_id 用户ID
	 * @return 用户奖项信息
	 * @throws Exception 
	 */

	@RequestMapping(value="/memberAward",method=RequestMethod.GET)
	public String memberAward1(@RequestHeader(value = "LANG", required = false) String lang,@RequestHeader (value="OS", required=false) String os,
			@RequestHeader (value="AUTHORIZATION", required=false) String token,
			@RequestHeader (value="SECRET", required=false)  String member_id,
			@RequestHeader(value = "SCREENWIDTH", required = false) String screenwidth,HttpServletRequest request, HttpServletResponse response,MemberVO memberVO) throws Exception{
		if(os != null){
			os = os.toLowerCase();
		}
		if (token != null && member_id != null) {
			memberVO = memberService.getMemberByIdCheck(member_id ,token, os);
			if (memberVO == null) {
				if ("ios".equals(os)) {
					response.setContentType("text/html;charset=utf-8");
					PrintWriter out = response.getWriter();
					out.print("<script  language='javascript'> window.webkit.messageHandlers.ios_show_toast.postMessage('您在别的地方已登录');window.webkit.messageHandlers.ios_login_error.postMessage('');</script>");
					out.flush();
					out.close();

				}else if ("android".equals(os)) {
					response.setContentType("text/html;charset=utf-8");
					PrintWriter out = response.getWriter();
					out.print("<script  language='javascript'>android.loginOut();</script>");
					out.flush();
					out.close();
				}
				return null;
			}else{
				if(PropertieUtil.loadPropertie("common_level").equals(memberVO.getLevel())){
					return "forward:ordinaryMember";
				}else{
					return "forward:unOrdinaryMember";
				}
			}
		}else{
			return "forward:ordinaryMember";
		}
		
	}
	/**
	 * @param token 令牌
	 * @param member_id 用户ID
	 * @return 未升级时_买手介绍页面
	 * @throws Exception 
	 */

	@RequestMapping(value="/ordinaryMember",method=RequestMethod.GET)
	public String ordinaryMember(@RequestHeader(value = "LANG", required = false) String lang,@RequestHeader (value="OS", required=false) String os,
	@RequestHeader (value="AUTHORIZATION", required=false) String token,
	@RequestHeader (value="SECRET", required=false)  String member_id,
	@RequestHeader(value = "SCREENWIDTH", required = false) String screenwidth,HttpServletRequest request, HttpServletResponse response,MemberVO memberVO) throws Exception{
		if(os != null){
			os = os.toLowerCase();
		}
		Map map  =  new HashMap();
		String host = configService.loadConfig("HOST");
		String version=configService.loadConfig("VERSION");
		List<GoodVO> goodList = getDefaultGoods(member_id,screenwidth,lang);
		List<GoodVO> goodList_d = goodService.packageGoodPrice(goodList);
		//上一个月超级买手
		List<PageEarnVO> super_buvers_ = memberService.getSuperBuyers(lang);
		if(super_buvers_.size()>0){
			List<PageEarnVO> super_buvers = memberService.packageBuversPrice(super_buvers_);
			String month_s= super_buvers.get(0).getMonth_s();
			if(lang ==null){
				request.setAttribute("month_s", month_s);
				request.setAttribute("super_buvers", super_buvers);
			}else{
				map.put("month_s", month_s);
				map.put("super_buvers", super_buvers);
			}
			
		}
		ShareVO shareVO =shareService.packageOrdinaryMemberShareInfo();
		
		if(lang ==null){
			request.setAttribute("goodList_d", goodList_d);
			request.setAttribute("shareVO", shareVO);
			request.setAttribute("host_url",host);
			request.setAttribute("member_id",member_id==null?"0":member_id);
			request.setAttribute("os", os);
			//普通会员 会员升级
		    request.setAttribute("levelupinfo_url",host+version+"/member/levelupInfo");
			//request.setAttribute("levelupinfo_url","http://10.0.0.68:8080/v2/member/levelupInfo");
		    //会员专享画面
	  		request.setAttribute("exclusiveMembership_url",host+version+"/good/exclusiveMembership");
	  		//request.setAttribute("exclusiveMembership_url","http://10.0.0.68:8080/v2/good/exclusiveMembership");
			return "/app/member/ordinaryMember";
		}else{
			
			 map.put("goodList_d", goodList_d);
			 map.put("shareVO", shareVO);
			 map.put("host_url",host);
			 map.put("member_id",member_id==null?"0":member_id);
			 map.put("os", os);
			 map.put("levelupinfo_url",host+version+"/member/levelupInfo");
			 map.put("exclusiveMembership_url",host+version+"/good/exclusiveMembership");
			 
		    response.setContentType("text/json;charset=utf-8");
	        PrintWriter out = response.getWriter();
	        out.print(JSON.toJSONString(PackageUtil.packageParams(200, "success", map, "")));
	        out.flush();
	        out.close();
	      return null;	
		}
		
	}
	/**
	 * @param token 令牌
	 * @param member_id 用户ID
	 * @return 升级后买手介绍页面
	 * @throws Exception 
	 */

	@RequestMapping(value="/unOrdinaryMember",method=RequestMethod.GET)
	public String unOrdinaryMember(@RequestHeader(value = "LANG", required = false) String lang,@RequestHeader (value="OS", required=false) String os,
			@RequestHeader (value="AUTHORIZATION", required=false) String token,
			@RequestHeader (value="SECRET", required=false)  String member_id,
			@RequestHeader(value = "SCREENWIDTH", required = false) String screenwidth,HttpServletRequest request, HttpServletResponse response,MemberVO memberVO) throws Exception{
		/*os="ios";
		member_id="3242";*/
		if(os != null){
			os = os.toLowerCase();
		}
		String host = configService.loadConfig("HOST");
		String version=configService.loadConfig("VERSION");
		GoodVO goodVO =new GoodVO();
		//获得收益
		String income_money = moneyService.getIncomeSumMoney(member_id)==null?"0.00":moneyService.getIncomeSumMoney(member_id);
		 request.setAttribute("income_money", income_money);
		//可使用电子提货劵
		int use_tickets=memberTicketService.selectUseTickets(member_id);
	    request.setAttribute("use_tickets", use_tickets);

		memberVO = memberService.getLevelByMemberId(member_id);
		memberVO.setLogo(memberVO.getLogo()+"?x-oss-process=image/resize,h_100");
		if("118".equals(memberVO.getIdentity())&&!memberVO.getLevel().equals(PropertieUtil.loadPropertie("expert_level"))&&!memberVO.getLevel().equals(PropertieUtil.loadPropertie("master_level"))){
			memberVO.setNeed_ticket(String.valueOf(Integer.parseInt(memberVO.getNext_ticket())-Integer.parseInt(memberVO.getCur_ticket())));
			//高级代理123
		}else if(memberVO.getLevel().equals(PropertieUtil.loadPropertie("expert_level"))){
			//团队有专家以上等级的数量
			String level_num  = memberService.getUpExpertNum(member_id, PropertieUtil.loadPropertie("expert_level"));
			memberVO.setLevel_num(level_num);
			//所有下级 包括自己的数量
			String childrenNum = memberService.getChildrenNum(member_id);
			memberVO.setChildren_num(childrenNum);
			//总代理
		}else if(memberVO.getLevel().equals(PropertieUtil.loadPropertie("master_level"))){
			//团队有专家以上等级的数量
			String level_num  = memberService.getUpExpertNum(member_id, PropertieUtil.loadPropertie("expert_level"));
			memberVO.setLevel_num(level_num);
			//所有下级 包括自己的数量
			String childrenNum = memberService.getChildrenNum(member_id);
			memberVO.setChildren_num(childrenNum);
		}
		
		request.setAttribute("member", memberVO);
		request.setAttribute("exp_state", memberVO.getExp_state());
		request.setAttribute("os",os);
		request.setAttribute("incomeandexpenseslog",host+version+"/money/incomeAndExpensesLog?incom_change=1");//收支明细
		//request.setAttribute("incomeandexpenseslog","http://10.0.0.68:8080/v2/money/incomeAndExpensesLog?incom_change=1");

		//代理级别以上会员 会员升级
		request.setAttribute("membershipupgrade_url",host+version+"/memberticket/MembershipUpgrade");
		//request.setAttribute("membershipupgrade_url","http://10.0.0.68:8080/v2/memberticket/MembershipUpgrade");

		//会员专享画面
		request.setAttribute("exclusiveMembership_url",host+version+"/good/exclusiveMembership");
		//request.setAttribute("exclusiveMembership_url","http://10.0.0.68:8080/v2/good/exclusiveMembership");
		//总代理进阶总代理考核
		request.setAttribute("masterinfo_url",host+version+"/member/masterInfo");
		//request.setAttribute("masterinfo_url","http://10.0.0.68:8080/v2/member/masterInfo");
		//赠送折扣体验劵画面
		request.setAttribute("giveDiscountLevel_url",host+version+"/friend/giveDiscountLevel");
		//request.setAttribute("giveDiscountLevel_url","http://10.0.0.68:8080/v2/friend/giveDiscountLevel");	
		//还不是付费会员画面
		request.setAttribute("novip_url",host+version+"/member/noVip");
		//request.setAttribute("novip_url","http://10.0.0.68:8080/v2/member/noVip");

		//兑换券名称从数据库查出来。
		request.setAttribute("ticket_name",configService.loadConfig("TICKET_NAME"));
		request.setAttribute("app_name",configService.loadConfig("APP_NAME"));
		
		request.setAttribute("host_url",host);
		//总代理名
	    String masterName = dicService.getNameById(PropertieUtil.loadPropertie("master_level"));
	    request.setAttribute("masterName", masterName);
	    //高级代理名
	    String expertLevel_name = dicService.getNameById(PropertieUtil.loadPropertie("expert_level"));
	    //普通会员 会员升级
	    request.setAttribute("levelupinfo_url",host+version+"/member/levelupInfo");
		//request.setAttribute("levelupinfo_url","http://10.0.0.68:8080/v2/member/levelupInfo");
	    //我的成长值
	    request.setAttribute("mygrowthvalue_url",host+version+"/member/myGrowthValue");
		//request.setAttribute("levelupinfo_url","http://10.0.0.68:8080/v2/member/myGrowthValue");
	    //会员专享价
		List<GoodVO> goodList_d = goodService.tempDefaultGoodList(member_id,screenwidth,lang);
		//会员成长值（说明）
		request.setAttribute("membergrowthvalue_url",host+version+"/member/memberGrowthValue");

	    request.setAttribute("goodList_d", goodList_d);
	    request.setAttribute("expertLevel_name", expertLevel_name);

		//纯兑换劵商品列表
		List<GoodVO> goodList_t = goodService.getGoodListT(goodVO);
		//图片缩放
		if(screenwidth != null && StringUtil.isNumeric(screenwidth)){
			goodService.processImg(goodList_t, screenwidth,4);
		}
		request.setAttribute("goodList_t", goodList_t);
		Map map = memberService.getCommonPopUpInfo(memberVO,os,"2",lang);
		MemberVO popup_info=memberService.popupPackage(map);
		request.setAttribute("popup_info", popup_info);
		return "/app/member/unOrdinaryMember";
	}
	
	public List<GoodVO> getDefaultGoods(String member_id,String screenwidth,String lang) throws Exception{
		GoodVO goodVO =new GoodVO();
		if(lang==null){
			goodVO.setCat_id(PropertieUtil.loadPropertie("member_default_cat"));
		}else{
			goodVO.setCat_id(PropertieUtil.loadPropertie("inter_member_default_cat"));
		}
		if(PropertieUtil.loadPropertie("package_cat").equals(goodVO.getCat_id())){
			goodVO.setPackage_yn("Y");
		}
		MemberVO memberVO = new MemberVO();
		if(member_id!=null &&!"".equals(member_id)){
			 memberVO=memberService.getAllInfoById(member_id);
		}else{
			memberVO.setLevel(PropertieUtil.loadPropertie("expert_level"));
		}
		goodVO.setLang(lang);
		List<GoodVO> list = goodService.getOrdinaryMemberGoodList(goodVO);
		//图片缩放
		if(screenwidth != null && StringUtil.isNumeric(screenwidth)){
			goodService.processImg(list, screenwidth,2);
		}
		if(!PropertieUtil.loadPropertie("package_cat").equals(goodVO.getCat_id())){
			list = goodService.processGoodList(list, memberVO, "券");
		}
		return list;
	}

	/**
	 * @param token 令牌
	 * @param member_id 用户ID
	 * @return 用户信息
	 */
	@ResponseBody
	@RequestMapping(value="/memberAwardForWeChat",method=RequestMethod.GET)
	public Object memberAwardForWeChat(@RequestHeader(value = "LANG", required = false) String lang,@RequestHeader (value="OS", required=false) String os,
			@RequestHeader (value="AUTHORIZATION", required=false) String token,
			@RequestHeader (value="SECRET", required=false)  String member_id,
			@RequestHeader(value = "SCREENWIDTH", required = false) String screenwidth,HttpServletRequest request, HttpServletResponse response,MemberVO memberVO,GoodVO goodVO) throws Exception{
		Map  map = new HashMap();
		//获得收益
		String income_money = moneyService.getIncomeSumMoney(member_id)==null?"0.00":moneyService.getIncomeSumMoney(member_id);
		map.put("income_money", income_money);
		//可使用电子提货劵
		int use_tickets=memberTicketService.selectUseTickets(member_id);
		map.put("use_tickets", use_tickets);
		memberVO = memberService.getLevelByMemberId(member_id);
		
		String host = configService.loadConfig("HOST");
		String version=configService.loadConfig("VERSION");

		if("118".equals(memberVO.getIdentity())&&!memberVO.getLevel().equals(PropertieUtil.loadPropertie("expert_level"))&&!memberVO.getLevel().equals(PropertieUtil.loadPropertie("master_level"))){
			memberVO.setNeed_ticket(String.valueOf(Integer.parseInt(memberVO.getNext_ticket())-Integer.parseInt(memberVO.getCur_ticket())));
			//高级代理123
		}else if(memberVO.getLevel().equals(PropertieUtil.loadPropertie("expert_level"))){
			//团队有专家以上等级的数量
			String level_num  = memberService.getUpExpertNum(member_id, PropertieUtil.loadPropertie("expert_level"));
			memberVO.setLevel_num(level_num);
			//所有下级 包括自己的数量
			String childrenNum = memberService.getChildrenNum(member_id);
			memberVO.setChildren_num(childrenNum);
			//总代理
		}else if(memberVO.getLevel().equals(PropertieUtil.loadPropertie("master_level"))){
			//团队有专家以上等级的数量
			String level_num  = memberService.getUpExpertNum(member_id, PropertieUtil.loadPropertie("expert_level"));
			memberVO.setLevel_num(level_num);
			//所有下级 包括自己的数量
			String childrenNum = memberService.getChildrenNum(member_id);
			memberVO.setChildren_num(childrenNum);
		}
		map.put("member", memberVO);
	    String masterName = dicService.getNameById(PropertieUtil.loadPropertie("master_level"));
	    map.put("masterName", masterName);
	    //高级代理名
	    String expertLevel_name = dicService.getNameById(PropertieUtil.loadPropertie("expert_level"));
	    //会员专享价
	    List<GoodVO> goodList_d = goodService.tempDefaultGoodList(member_id,screenwidth,lang);

	    map.put("goodList_d", goodList_d);

  		//纯兑换劵商品列表
	    goodVO.setLang(lang);
  		List<GoodVO> goodList_t = goodService.getGoodListT(goodVO);
  		map.put("goodList_t", goodList_t);
  		map.put("app_name",configService.loadConfig("APP_NAME"));
  		map.put("rate_dollar",configService.loadConfig("RATE_DOLLAR"));
  		Map popup_info = memberService.getCommonPopUpInfo(memberVO,os,"2",lang);
  		map.put("popup_info", popup_info);
  		//我的成长值
  		map.put("mygrowthvalue_url",host+version+"/member/myGrowthValue");
		return PackageUtil.packageParams(200,"successs",map,""); 
	}
	/**
	 * @param token 令牌
	 * @param member_id 用户ID
	 * @return noVip
	 * @throws Exception 
	 */

	@RequestMapping(value="/noVip",method=RequestMethod.GET)
	public String noVip(@RequestHeader (value="OS", required=false) String os,
			@RequestHeader (value="AUTHORIZATION", required=false) String token,
			@RequestHeader (value="SECRET", required=false)  String member_id,
			@RequestHeader(value = "SCREENWIDTH", required = false) String screenwidth,HttpServletRequest request, HttpServletResponse response,MemberVO memberVO,String type) throws Exception{
		if(os != null){
			os = os.toLowerCase();
		}
		String host = configService.loadConfig("HOST");
		String version=configService.loadConfig("VERSION");
		//普通会员 会员升级
		request.setAttribute("levelupinfo_url",host+version+"/member/levelupInfo");
		//request.setAttribute("levelupinfo_url","http://10.0.0.68:8080/v2/member/levelupInfo");
		request.setAttribute("os", os);
		request.setAttribute("type",type);
	    return "/app/member/noVip";
	}
	/**
	 * 我的成长值
	 * @param token 令牌
	 * @param member_id 用户ID
	 * @return noVip
	 * @throws Exception 
	 */

	@RequestMapping(value="/myGrowthValue",method=RequestMethod.GET)
	public String myGrowthValue(@RequestHeader (value="OS", required=false) String os,
			@RequestHeader (value="AUTHORIZATION", required=false) String token,
			@RequestHeader (value="SECRET", required=false)  String member_id,
			HttpServletRequest request, HttpServletResponse response,MemberVO memberVO,String isJSON,LogTicketVO logTicketVO) throws Exception{
		if(os != null){
			os = os.toLowerCase();
		}
		Map<String, Object> map = new HashMap<String, Object>();
		/*member_id="2591";*/
		memberVO = memberService.getAllInfoById(member_id);
		logTicketVO.setMember_id(member_id);
		int total = logTicketService.getTotalByType1(logTicketVO);
		logTicketVO.setPagination(logTicketVO.getPage_index(),total+"");
		List<LogTicketVO> list = logTicketService.getListByType1(logTicketVO);
		String host = configService.loadConfig("HOST");
		String version=configService.loadConfig("VERSION");
		if(!"1".equals(isJSON)){
			request.setAttribute("ticket_name",configService.loadConfig("TICKET_NAME"));
			//request.setAttribute("membergrowthvalue_url","http://10.0.0.68:8080/v2/member/memberGrowthValue");
			request.setAttribute("os", os);
			request.setAttribute("memberId", member_id);
			request.setAttribute("token", token);
			request.setAttribute("cur_ticket",memberVO.getHistory_total_ticket());
			request.setAttribute("list",list);
		    return "/app/member/myGrowthValue";
		}else{
			LogTicketVO pagination = logTicketService.packPaginationInfo(logTicketVO);
			map.put("pagination", pagination);
			map.put("ticket_name",configService.loadConfig("TICKET_NAME"));
			map.put("membergrowthvalue_url",host+version+"/member/memberGrowthValue");
			map.put("os", os);
			map.put("cur_ticket",memberVO.getHistory_total_ticket());
			map.put("list",list);
			response.setContentType("text/html;charset=utf-8");
			PrintWriter out = response.getWriter();
	        out.print(JSON.toJSONString(PackageUtil.packageParams(200, "success", map, "")));
	        out.flush();
	        return null;
		}
		
	}
	/**
	 * 我的成长值分页
	 * @param token 令牌
	 * @param member_id 用户ID
	 * @return noVip
	 * @throws Exception 
	 */
	
	@RequestMapping(value="/myGrowthValueItem",method=RequestMethod.GET)
	public String myGrowthValueItem(@RequestHeader (value="OS", required=false) String os,
			@RequestHeader (value="AUTHORIZATION", required=false) String token,	
			@RequestHeader (value="SECRET", required=false)  String member_id,
			HttpServletRequest request, HttpServletResponse response,MemberVO memberVO,String isJSON,LogTicketVO logTicketVO) throws Exception{
		if(os != null){
			os = os.toLowerCase();
		}
		Map<String, Object> map = new HashMap<String, Object>();
		logTicketVO.setMember_id(member_id);
		int total = logTicketService.getTotalByType1(logTicketVO);
		logTicketVO.setPagination(logTicketVO.getPage_index(),total+"");
		List<LogTicketVO> list = logTicketService.getListByType1(logTicketVO);
		
		String host = configService.loadConfig("HOST");
		String version=configService.loadConfig("VERSION");
		String ticket_name=configService.loadConfig("TICKET_NAME");
		
		if(!"1".equals(isJSON)){
			request.setAttribute("ticket_name",ticket_name);
			//request.setAttribute("membergrowthvalue_url","http://10.0.0.68:8080/v2/member/memberGrowthValue");
			request.setAttribute("os", os);
			request.setAttribute("memberId", member_id);
			request.setAttribute("token", token);
			request.setAttribute("list",list);
			return "/app/member/myGrowthValueItem";
		}else{
			LogTicketVO pagination = logTicketService.packPaginationInfo(logTicketVO);
			map.put("pagination", pagination);
			map.put("ticket_name",ticket_name);
			map.put("membergrowthvalue_url",host+version+"/member/memberGrowthValue");
			map.put("os", os);
			map.put("list",list);
			response.setContentType("text/html;charset=utf-8");
			PrintWriter out = response.getWriter();
			out.print(JSON.toJSONString(PackageUtil.packageParams(200, "success", map, "")));
			out.flush();
			return null;
		}
		
	}
	/**
	 * 会员成长值（说明）
	 * @param token 令牌
	 * @param member_id 用户ID
	 * @return noVip
	 * @throws Exception 
	 */
	
	@RequestMapping(value="/memberGrowthValue",method=RequestMethod.GET)
	public String memberGrowthValue(@RequestHeader (value="OS", required=false) String os,
			@RequestHeader (value="AUTHORIZATION", required=false) String token,
			@RequestHeader (value="SECRET", required=false)  String member_id,
			HttpServletRequest request, HttpServletResponse response,MemberVO memberVO) throws Exception{
		
		String host = configService.loadConfig("HOST");
		request.setAttribute("host_url",host);
		return "/app/member/memberGrowthValue";
	}
	
}

